﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;
using System.Data;
using System.Text;

namespace IHISCETeim.Web.MachineSys.UserModel
{
    public partial class UClaimDemageItemCodeTongJiReport : PageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.查看 };
            }
        }
        protected override string DWZRef
        {
            get
            {
                return "UClaimDemageItemCodeTongJiReport";
            }
        }
        #region 属性 (查询条件)

        protected int Year
        {
            get
            {
                return GetRequestValue<int>("year", DateTime.Now.Year);
            }
        }
        protected int Month
        {
            get
            {
                return GetRequestValue<int>("Month", DateTime.Now.Month);
            }
        }
       
        protected string colMonth
        {
            get
            {
                return Year.ToString() + "-" + Month.ToString();
            }
        }
        protected DateTime stated
        {
            get
            {
                return Convert.ToDateTime(colMonth);
            }
        }

        protected DateTime endd
        {
            get
            {
                return stated.AddMonths(1).AddDays(-1);
            }
        }

       

       
        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {            
            DataBind();
            if (GetRequestValue<string>("exportexecl", "0") == "1")
            {
                
            }
            AddLog(Permission.查看);
        }
        protected DataTable SUMDT = null;
        protected void DataBind()
        {
            DataTableCollection DTC = UClaimDemageController.GetItemCodeTongJiReport(stated.ToString("yyyy-MM-dd"), endd.ToString("yyyy-MM-dd"));
            this.rpMenu.DataSource = DTC[0];
            this.rpMenu.DataBind();
            SUMDT = DTC[1];
        }

        protected string GetYearList()
        {
            string liTemplete = "<option value='{0}' {1}>{0}年</option>";
            string rHtml = "";
            int nowYear = DateTime.Now.Year;
            for (int i = (nowYear - 3); i <= nowYear; i++)
            {
                rHtml = rHtml + string.Format(liTemplete, i, i == Year ? "selected" : "");
            }
            return rHtml;
        }


        protected string GetViewUClaimDemageControl(object cdList)
        {
            try
            {
                string cdNumStr = cdList.ToString();
                if (cdNumStr.Trim().Length <= 1)
                    return "";
                string[] cdNumStrArr = cdNumStr.Split(new char[] { ',' });
                StringBuilder sb = new StringBuilder();
                foreach (string itm in cdNumStrArr)
                {
                    sb.AppendFormat("<a href=\"UserModel/UClaimDemageControlEdit.aspx?ClaimsNumber={0}\" target=\"dialog\" title=\"查看代理商索赔完成报告单\" rel=\"UClaimDemageControlEdit\" max=\"false\" mask=\"true\" maxable=\"false\" minable=\"false\" resizable=\"false\" drawable=\"true\" width=\"850\" height=\"450\">{0}</a> | ", itm);
                }

                return sb.ToString();
            }
            catch
            {
                return "";
            }
        }
    }
}